package com.bigdata.spark.core.framework.util

import org.apache.spark.SparkContext

/**
 * sc 环境变量工具
 * ThreadLocal可以对线程的内存进行控制，存储数据，共享数据。
 */
object EnvUtil {
  private val scLocal = new ThreadLocal[SparkContext]()

  def put(sc: SparkContext):Unit = {
    scLocal.set(sc)
  }

  def take():SparkContext = {
    scLocal.get()
  }

  def clear():Unit =  {
    scLocal.remove()
  }
}
